<?php
// 定义星座列表
$constellations = [
    "白羊座", "金牛座", "双子座",
    "巨蟹座", "狮子座", "处女座",
    "天秤座", "天蝎座", "射手座",
    "摩羯座", "水瓶座", "双鱼座"
];

// 定义行星列表
$planets = [
    "太阳", "月亮", "水星",
    "金星", "火星", "木星",
    "土星", "天王星", "海王星",
    "冥王星"
];

// 定义宫位列表
$houses = [
    "第一宫", "第二宫", "第三宫",
    "第四宫", "第五宫", "第六宫",
    "第七宫", "第八宫", "第九宫",
    "第十宫", "第十一宫", "第十二宫"
];

// 随机生成星盘信息
function generateAstroChart($constellations, $planets, $houses) {
    $chart = [];
    foreach ($planets as $planet) {
        $randomConstellation = $constellations[array_rand($constellations)];
        $randomHouse = $houses[array_rand($houses)];
        $chart[$planet] = [
            "constellation" => $randomConstellation,
            "house" => $randomHouse
        ];
    }
    return $chart;
}

// 处理生成星盘的请求
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $chart = generateAstroChart($constellations, $planets, $houses);
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>星座星盘网页游戏</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            background-color: #f4f4f4;
        }

        h1 {
            color: #333;
        }

        form {
            margin-top: 20px;
        }

        button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #007BFF;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 5px;
        }

        button:hover {
            background-color: #0056b3;
        }

        #chart {
            margin-top: 20px;
            padding: 20px;
            background-color: white;
            border-radius: 5px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
            display: inline-block;
            text-align: left;
        }

        #chart h2 {
            margin-bottom: 10px;
        }

        #chart ul {
            list-style-type: none;
            padding: 0;
        }

        #chart li {
            margin-bottom: 5px;
        }
    </style>
</head>

<body>
    <h1>星座星盘网页游戏</h1>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
        <button type="submit">生成星盘</button>
    </form>
    <?php
    if (isset($chart)) {
        echo '<div id="chart">';
        foreach ($chart as $planet => $info) {
            echo '<h2>' . $planet. '</h2>';
            echo '<ul>';
            echo '<li>所在星座: ' . $info["constellation"] . '</li>';
            echo '<li>所在宫位: ' . $info["house"] . '</li>';
            echo '</ul>';
        }
        echo '</div>';
    }
    ?>
</body>

</html>